package poiTests;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

import POI.GeoInfo;
import POI.LocationType;

public class GeoInfoTest extends TestCase {

	GeoInfo giCh,giLv,giKv,giSc;
	
	@Before
    public void setUp() {
		giCh = new GeoInfo(1,"Chernivtsi","My",48.3,25.933);
		giLv = new GeoInfo(2,"L'viv","Store",49.85,24.0167);
		giKv = new GeoInfo(3,"Kyiv","Food",50.45,30.5233);
		giSc = new GeoInfo(4,"Suceava","Recreation",47.651389,26.2556);
    }
	@Test
	public void testSetLocationTypeName() {
		giCh.setLocationTypeName("Recreation");
		assertEquals("Recreation",giCh.getLocationTypeName()); 
		giLv.setLocationTypeName("My");
		assertEquals("My",giLv.getLocationTypeName());
		giKv.setLocationTypeName("Store");
		assertEquals("Store",giKv.getLocationTypeName());
		giSc.setLocationTypeName("Food");
		assertEquals("Food",giSc.getLocationTypeName());
	}

	@Test
	public void testGetLatitude() {
		assertTrue(Math.abs(giCh.getLatitude()-48.3)<0.00001); 
		assertTrue(Math.abs(giLv.getLatitude()-49.85)<0.00001); 
		assertTrue(Math.abs(giKv.getLatitude()-50.45)<0.00001); 
		assertTrue(Math.abs(giSc.getLatitude()-47.651389)<0.00001); 
	}

	@Test
	public void testGetLongtitude() {
		assertTrue(Math.abs(giCh.getLongtitude()-25.933)<0.00001); 
		assertTrue(Math.abs(giLv.getLongtitude()-24.0167)<0.00001); 
		assertTrue(Math.abs(giKv.getLongtitude()-30.5233)<0.00001); 
		assertTrue(Math.abs(giSc.getLongtitude()-26.2556)<0.00001); 
	}

	@Test
	public void testGetLocationType() {
		assertEquals(LocationType.MY, giCh.getLocationType());
		assertEquals(LocationType.STORE, giLv.getLocationType());
		assertEquals(LocationType.FOOD, giKv.getLocationType());
		assertEquals(LocationType.RECREATION, giSc.getLocationType());
	}

	@Test
	public void testGetLocationName() {
		assertEquals("Chernivtsi", giCh.getLocationName());
		assertEquals("L'viv", giLv.getLocationName());
		assertEquals("Kyiv", giKv.getLocationName());
		assertEquals("Suceava", giSc.getLocationName());
	}

	@Test
	public void testGetID() {
		assertEquals(1, giCh.getID());
		assertEquals(2, giLv.getID());
		assertEquals(3, giKv.getID());
		assertEquals(4, giSc.getID());	
	}

	@Test
	public void testGetLocationTypeName() {
		assertEquals("My", giCh.getLocationTypeName());
		assertEquals("Store", giLv.getLocationTypeName());
		assertEquals("Food", giKv.getLocationTypeName());
		assertEquals("Recreation", giSc.getLocationTypeName());
	}

	@Test
	public void testToString() {
		assertEquals("1,Chernivtsi,My,48.3,25.933", giCh.toString());
		assertEquals("2,L'viv,Store,49.85,24.0167", giLv.toString());
		assertEquals("3,Kyiv,Food,50.45,30.5233", giKv.toString());
		assertEquals("4,Suceava,Recreation,47.651389,26.2556", giSc.toString());
	}

}
